var gulp = require('gulp');

var htmlmin = require('gulp-htmlmin'),
    imagemin = require('gulp-imagemin'),
    pngcrush = require('imagemin-pngcrush'),
    minifycss = require('gulp-minify-css'),
    jshint = require('gulp-jshint'),
    uglify = require('gulp-uglify'),
    concat = require('gulp-concat'),
    rename = require('gulp-rename'),
    notify = require('gulp-notify');

gulp.task('html', function() {
  return gulp.src('*.html')
    .pipe(htmlmin({collapseWhitespace: true}))
    .pipe(gulp.dest('./dist'))
    .pipe(notify({ message: 'html task ok' }));
});

gulp.task('img', function() {
  return gulp.src('src/images/*')
    .pipe(imagemin({
        progressive: true,
        svgoPlugins: [{removeViewBox: false}],
        use: [pngcrush()]
    }))
    .pipe(gulp.dest('./dist/images/'))
    .pipe(notify({ message: 'img task ok' }));
});

gulp.task('css', function() {
  return gulp.src('assets/css/*.css')
    .pipe(gulp.dest('dist/assets/css'))
    .pipe(notify({ message: 'css task ok' }));
});

gulp.task('lint', function() {
  return gulp.src('assets/js/*.js')
    .pipe(jshint())
    .pipe(jshint.reporter('default'))
    .pipe(notify({ message: 'lint task ok' }));
});

gulp.task('js', function() {
  return gulp.src('assets/js/*.js')
    .pipe(gulp.dest('dist/assets/js'))
    .pipe(notify({ message: 'js task ok' }));
});

gulp.task('default', function(){
  gulp.run('img', 'css', 'lint', 'js', 'html');
});